package model

import (
	"strconv"
	"time"
)

func Gt(field string, value any) (string, any) {
	return field + " > ?", value
}

func GtEq(field string, value any) (string, any) {
	return field + " >= ?", value
}

func Lt(field string, value any) (string, any) {
	return field + " < ?", value
}

func LtEq(field string, value any) (string, any) {
	return field + " <= ?", value
}

func Eq(field string, value any) (string, any) {
	return field + " = ?", value
}

type Time struct {
	time.Time
}

func (t *Time) UnmarshalJSON(data []byte) error {
	num, err := strconv.ParseInt(string(data), 10, 64)
	if err != nil {
		return err
	}
	t.Time = time.Unix(num, 0)
	return nil
}
